package fumec.br.ia.search;

import java.util.Stack;

public class Solucao {
	private Double custo = null;
	private Stack<IAcao> pilha = new Stack<IAcao>();

	public Solucao(No no){
		if(no != null){
			this.custo = no.getCusto();
			
			while(no.getPai() != null){
				pilha.push(no.getAcao());
				no = no.getPai();
			}
		}
	}
	
	public Stack<IAcao> getSolucao(){
		return this.pilha;
	}
	
	public Double custo(){
		return this.custo;
	}
	
	public String toString(){
		String solucao = "";
		String virgula = "";
		for(int i = this.pilha.size()-1; i >= 0; i--){
			solucao = solucao+virgula+this.pilha.get(i).getDestino();
			virgula = ",";
		}
		return solucao;
	}
}